﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DXApplicationTangche.UC.项目流程.Service;
using DXApplicationTangche.UC.样品管理.样品订单预览;

namespace DXApplicationTangche.UC.项目流程.流程UC
{
    public partial class XtraUserControl任务相关信息 : DevExpress.XtraEditors.XtraUserControl
    {
        private string orderId;
        private OrderTaskAndParentFacadeDTO orderTtaskAndParentFacadeDTO;
        
        public XtraUserControl任务相关信息(String wbsTemplateId, String orderId, String code)
        {
            InitializeComponent();
            this.orderId = orderId;
            this.orderTtaskAndParentFacadeDTO = 流程Service.getOrderTaskAndParentFacade(wbsTemplateId, orderId, code);
            //当前任务
            this.textBox计划开始时间.Text = orderTtaskAndParentFacadeDTO.currentOrderTaskDTO.startTimePlanned == DateTime.MinValue ? "" : orderTtaskAndParentFacadeDTO.currentOrderTaskDTO.startTimePlanned.ToString();
            this.textBox实际完成时间.Text = orderTtaskAndParentFacadeDTO.currentOrderTaskDTO.actualFinishDate == DateTime.MinValue ? "" : orderTtaskAndParentFacadeDTO.currentOrderTaskDTO.actualFinishDate.ToString();
            this.textBox工作描述.Text = orderTtaskAndParentFacadeDTO.currentOrderTaskDTO.activityDescription;
            this.textBox任务负责人.Text = orderTtaskAndParentFacadeDTO.currentOrderTaskDTO.responsor;
            this.textBox完成标识.Text = orderTtaskAndParentFacadeDTO.currentOrderTaskDTO.done ? "完成" : "未完成";
            this.textBox执行人.Text = orderTtaskAndParentFacadeDTO.currentOrderTaskDTO.assignee;
            //父任务
            this.textBox计划开始时间1.Text = orderTtaskAndParentFacadeDTO.parentOrderTaskDTO.startTimePlanned == DateTime.MinValue ? "" : orderTtaskAndParentFacadeDTO.parentOrderTaskDTO.startTimePlanned.ToString();
            this.textBox实际完成时间1.Text = orderTtaskAndParentFacadeDTO.parentOrderTaskDTO.actualFinishDate == DateTime.MinValue ? "" : orderTtaskAndParentFacadeDTO.parentOrderTaskDTO.actualFinishDate.ToString();
            this.textBox工作描述1.Text = orderTtaskAndParentFacadeDTO.parentOrderTaskDTO.activityDescription;
            this.textBox任务负责人1.Text = orderTtaskAndParentFacadeDTO.parentOrderTaskDTO.responsor;
            if (!String.IsNullOrWhiteSpace(this.textBox工作描述1.Text))
            {
                this.textBox完成标识1.Text = orderTtaskAndParentFacadeDTO.parentOrderTaskDTO.done ? "完成" : "未完成";
            }
            this.textBox执行人1.Text = orderTtaskAndParentFacadeDTO.parentOrderTaskDTO.assignee;
            //子任务
            this.gridControl子任务清单.DataSource = orderTtaskAndParentFacadeDTO.childOrderTaskDTOs;
        }

        private void simpleButton查看订单_Click_1(object sender, EventArgs e)
        {
            new Form样品订单预览新(this.orderId).ShowDialog();

        }

        //无成果物 MessageBox弹窗，有成果物 成果物预览
        private void simpleButton任务完成_Click(object sender, EventArgs e)
        {
            new Form成果物预览(this.orderTtaskAndParentFacadeDTO.currentOrderTaskDTO).ShowDialog();
        }
    }
}
